package com.revoltingdevelopment.perquackey;

/* Roll the full set of Perquackey Dice
	* @return via showNormal() char[10] the 10 characters of the normal Perquackey Dice 
	* @return via showVulnerable() char[3] the 3 characters of the normal Perquackey Dice 
**/
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class PerquackeyDiceRoll	{
	public static void main(String[] args)
	{
		PerquackeyDiceRoll thing = new PerquackeyDiceRoll();
		char[] normalCup = new char[thing.showNormalLength()];	
		char[] vulnerableCup = new char[thing.showVulnerableLength()];	
		normalCup = thing.showNormal();
		vulnerableCup = thing.showVulnerable();
		for (int i=0; i < normalCup.length; i++)	{
			System.out.println ("Normal " + i + ": " + normalCup[i]);
		}
		for (int i=0; i < vulnerableCup.length; i++)	{
			System.out.println ("vulnerableCup " + i + ": " + vulnerableCup[i]);
		}

        }

	public PerquackeyDiceRoll()	{
		normalCup = MakeTheNormalCup();
		vulnerableCup = MakeTheVulnerableCup();
		}

	private PerquackeyDie[] MakeTheNormalCup() {
		PerquackeyDie[] normalPQCup = new PerquackeyDie[normalLength];
		for (int i=0; i < normalLength; i++)	{
			normalPQCup[i] = new PerquackeyDie(i+1);
			}
		return normalPQCup;
	}
	private PerquackeyDie[] MakeTheVulnerableCup() {
		PerquackeyDie[] vulnerablePQCup = new PerquackeyDie[vulnerableLength];
		for (int i=0; i < vulnerableLength; i++)	{
			vulnerablePQCup[i] = new PerquackeyDie(i+1);
			}
		return vulnerablePQCup;
	}
	public char[] showNormal()	{
		char[] charNormalCup = new char[normalLength];
		for (int i=0; i < normalLength; i++)	{
			charNormalCup[i] = this.normalCup[i].getPerquackeyDieLetter();
			}
		return charNormalCup;
	}
	public char[] showVulnerable()	{
		char[] charVulnerableCup = new char[vulnerableLength];
		for (int i=0; i < vulnerableLength; i++)	{
			charVulnerableCup[i] = this.vulnerableCup[i].getPerquackeyDieLetter();
			}
		return charVulnerableCup;
	}
	public int showNormalLength()	{
		return normalLength;
	}
	public int showVulnerableLength()	{
		return vulnerableLength;
	}

        public boolean isInRoll(String theWord, boolean isVuln)   {
            String showMyLetters = new String(this.showNormal());
            String showMyVulnerables = new String(this.showVulnerable());
            boolean wordLetterFound;
            if (isVuln) {
                showMyLetters += showMyVulnerables;
            }
            for (int i=0;i<theWord.length();i++) {
                String l = Character.toString(theWord.charAt(i));
                if (showMyLetters.contains(l))  {
                        showMyLetters = showMyLetters.replaceFirst(l, "_");
                }
                else    {
                    return false;
                }
            }

            return true; // comes here if it makes it through i
           }
        private int normalLength = 10;
	private int vulnerableLength = 3;
	private PerquackeyDie[] normalCup = new PerquackeyDie[normalLength];
	private PerquackeyDie[] vulnerableCup = new PerquackeyDie[vulnerableLength];
}
